<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if isset($billPlatform) && $billPlatform eq 2}-->澳粒<!--{/if}-->退货单列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<div class="container">

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form class="form-inline" id="search_form" onsubmit="return false;">

                        <!--{if isset($billPlatform) && $billPlatform eq 2}-->
                        <input type="hidden" name="billPlatform" value="2"/>
                        <!--{/if}-->

                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>退货单编号：<input type="text" class="form-control w120" name="return_no" value="<!--{$kf_return_no|default:''}-->"></span>
                                    <span>订单编号：<input type="text" class="form-control w120" name="bill_code"></span>
                                    <span>会员名：<input type="text" class="form-control w120" name="custID"></span>
                                    <span>
                                        退货单状态：<select class="form-control" id="return_status" name="return_status">
                                            <option value="-1">请选择</option>
                                            <option value="1">未审核</option>
                                            <option value="2">已审核</option>
                                            <option value="3">已收货</option>
                                            <option value="4">已取消</option>
                                            <option value="5">已配送自购</option>
                                        </select>
                                    </span>
                                    <span>
                                        退货原因：<select class="form-control" id="second_id" name="return_reason_id_1" style="width: 120px;margin-right: 10px;">
                                            <option value="">请选择</option>
                                        </select>
                                        <select class="form-control" id="third_id" name="return_reason_id_2" style="width: 180px;">
                                            <option value="">请选择</option>
                                        </select>
                                    </span>

                                    <span>
                                        配送站：<select class="form-control" id="distribution_id" name="distribution_id">
                                            <option value="">请选择</option>
                                            <!--{foreach from=$distribution_array item=value}-->
                                            <option value="<!--{$value.distribution_id}-->"><!--{$value.distribution_name}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>
                                    <span>
                                        配送日期：
                                        <input class="form-control w100" id="sendDate" name="sendDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear3();">清 空</button>
                                    </span>
                                    <span>
                                        创建日期：
                                        <input class="form-control w100" id="startDate" name="startDate" value="" readonly="readonly" type="text" />
                                        ～
                                        <input class="form-control w100" id="endDate" name="endDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear1();">清 空</button>
                                    </span>
                                    <span>
                                        审核日期：
                                        <input class="form-control w100" id="auditStartDate" name="auditStartDate" value="" readonly="readonly" type="text" />
                                        ～
                                        <input class="form-control w100" id="auditEndDate" name="auditEndDate" value="" readonly="readonly" type="text" />
                                        <button type="button" class="btn btn-default btn-sm" onclick="bill.timeClear2();">清 空</button>
                                    </span>

                                    <span>
                                        备注：<input type="text" class="form-control w300" name="return_memo">
                                    </span>

                                    <span>
                                        <button type="button" class="btn btn-primary" onclick="bill.search();">查 询</button>&nbsp;&nbsp;
                                        <button type="button" class="btn btn-warning" onclick="bill.clear();">重 置</button>
                                    </span>

                                </td>
                            </tr>

                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>

<script type="text/javascript">

// del  by allen.qiang allen.qiang@fistforward.com 2015年2月27日 退货单查询界面保存布局 FUN-BK-0048 end


  /*  $("#flex").flexigrid({
        url:"/invokingAjax-backend/bill/billReturn.ajax?operFlg=1&xjx=none",
        dataType: "json",
        colModel : [
            {display: "操作", width : 100, align: "center"},
            {display: "状态", width : 100, align: "center"},
            {display: "退货单编号", name : "return_no", width : 100, align : 'center' ,sortable : true},
            {display: "订单编号", align : 'center' , width : 130 },
            //add by allen.qiang 20141127 FUN-BK-0039-退货单查询界面增加“退货商品”字段列 ---start
            {display: "退货商品名称",  width : 160 },
            //add by allen.qiang 20141127 FUN-BK-0039-退货单查询界面增加“退货商品”字段列 ---end
            {display: "订单平台", align : 'center' , width : 130 },
            //add by allen.qiang 20141024 退货单增加“配送日期”作为查询条件--start
            {display: "配送时间", width : 200},
            //add by allen.qiang 20141024 退货单增加“配送日期”作为查询条件--end
            {display: "会员名", width : 100},
            {display: "联系人", width : 100},
            {display: "手机号码", width : 100},
            {display: "退货原因", width : 120},
            //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- start
            {display: "责任部门", width : 90},
            {display: "品控意见", width : 150},
            //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- end
            {display: "配送站", width : 100},
            {display: "创建人", width : 80},
            {display: "创建时间", width : 150},
            {display: "备注", width : 300},
            {display: "审核人", width : 80},
            {display: "审核时间", width : 150},
            {display: "收货人", width : 80},
            {display: "收货时间", width : 150},
            {display: "取消人", width : 80},
            {display: "取消时间", width : 150},
            //add by allen.qiang 20141110 FUN-BK-0022-配送部自购业务需求 --start
            {display: "自购操作人", width : 90},
            {display: "自购操作时间", width : 150}
            //add by allen.qiang 20141110 FUN-BK-0022-配送部自购业务需求 --end
        ],
        sortname: "return_no",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });
    */


    //del  by allen.qiang allen.qiang@fistforward.com 2015年2月27日 退货单查询界面保存布局 FUN-BK-0048 end





     //add by allen.qiang allen.qiang@fistforward.com 2015年2月27日 退货单查询界面保存布局 FUN-BK-0048 start


    var table_id = <!--{$table_id}-->;
    var fixed_json = <!--{$fixed_json}-->;
    var is_AL=<!--{$is_AL}-->;
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/bill/billReturn.ajax?operFlg=1&xjx=none",
        dataType: "json",
        colModel : fixed_json,
        sortname: "bill_no",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        },

        //拉伸宽度后触发
        onColResize:function(){

            if(is_AL!=1){
                var last_cid = arguments[0];
                var width = arguments[1];

                E.ajax_get({
                    url:'/invokingAjax-backend/system/flexigrid.ajax?operFlg=1',
                    data:{
                        table_id:table_id,
                        last_cid:last_cid,
                        width:width
                    },
                    call:function( o ){ }

                });
            }


        },

        //隐藏后触发
        onToggleCol:function(){
            if(is_AL!=1){
                var cid = arguments[0];
                var hide = arguments[1];
                E.ajax_get({
                    url:'/invokingAjax-backend/system/flexigrid.ajax?operFlg=3',
                    data:{
                        table_id:table_id,
                        cid:cid,
                        hide:hide
                    },
                    call:function( o ){ }

                });
            }

        },

        //拖拽后触发
        onDragCol:function(){
            if(is_AL!=1){
                var cid = arguments[0];
                var last_cid = arguments[1];

                E.ajax_get({
                    url:'/invokingAjax-backend/system/flexigrid.ajax?operFlg=2',
                    data:{
                        table_id:table_id,
                        cid:cid,
                        last_cid:last_cid
                    },
                    call:function( o ){ }

                });
            }

        }

    });



     //add by allen.qiang allen.qiang@fistforward.com 2015年2月27日 退货单查询界面保存布局 FUN-BK-0048 end




    var bill = {

        return_no: '',

        search: function() {
            var dt = $("#search_form").serializeArray();
            $("#flex").flexOptions({newrp: 1, params: dt}).flexReload();
        },

        load: function() {
            $("#flex").flexReload();
        },

        clear : function (){
            $(".form-control").val('');
            $("#second_id").val('');
            $("#third_id").val('');
            $("#return_status").val(-1);
            this.search();
        },
        timeClear1: function() {
            $('#startDate').val('');
            $('#endDate').val('');
        },
        timeClear2: function() {
            $('#auditStartDate').val('');
            $('#auditEndDate').val('');
        },
        //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--start
        timeClear3: function() {
            $('#sendDate').val('');
        },
        //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--end

        //订单详情
        billview: function( bill_no ) {
            window.open('/quanliadmin/app/bill/billSearch.pscript?operFlg=9&bill_no=' + bill_no);
        },

        view: {

            open: function( return_no, operFlg ) {

                bill.return_no = return_no;
                this.operFlg = operFlg;

                E.ajax_get({
                    url: '/invokingAjax-backend/bill/billReturn.ajax?operFlg=7&xjx=none',
                    data: {
                        return_no: return_no
                    },
                    call: 'bill.view.result'
                });

            },

            //add by allen.qiang 20141110 FUN-BK-0022-配送部自购业务需求 --start
            purchase: function( return_no ) {

                bill.return_no = return_no;

                E.ajax_get({
                    url: '/invokingAjax-backend/bill/billReturn.ajax?operFlg=7&xjx=none',
                    data: {
                        return_no: return_no
                    },
                    call: 'bill.view.result_purchase'
                });

            },
            result_purchase: function( o ) {

                if (o.code == 200) {

                    var return_obj = o.data;

                    var bill_totalMoney=0; //商品总金额
                    var buyMoney=0; //配件总金额
                    if(return_obj.return_goods!=undefined){
                        $.each(return_obj.return_goods, function(k, v) {
                            bill_totalMoney+=parseFloat(v.goods_storePrice);
                            buyMoney+=parseFloat(v.buyMoney);
                        });
                    }

                    var return_price=0; //退货金额
                    if(return_obj.pay!=undefined){
                        $.each(return_obj.pay,function(key,value){
                            if(value.payTypeID!=2 && value.payTypeID!=3){ //排除余额和积分
                                return_price+=parseFloat(value.return_pay);
                            }
                        });
                    }

                    var purchase_price =parseFloat(bill_totalMoney)*0.5+buyMoney; //配送自购金额

                    var html = '<div class="panel panel-default form-horizontal">';
                    html += '<div class="panel-heading">退货单详情</div>';
                    html += '<div class="panel-body">';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">订单编号：</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.bill_code + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">退货单号：</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.return_no + '</p>';
                    html += '</div>';
                    html += '</div>';

                    //add by 20141028 sunqiang FUN-BK-0012 退货单默认退货金额 start
                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">退货金额：</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_price.toFixed(2) + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '</div>';
                    html += '</div>';

                    html += '<div class="panel panel-default">';
                    html += '<div class="panel-heading">配送自购商品信息</div>';
                    html += '<table class="table">';
                    html += '<thead>';
                    html += '<tr>';
                    html += '<th width="*">商品名称</th>';
                    html += '<th width="110" class="tac">规格</th>';
                    html += '<th width="110" class="tac">自购数量</th>';
                    html += '<th width="110" class="tac">销售价</th>';
                    html += '<th width="110" class="tac">配件总金额</th>';
                    html += '</tr>';
                    html += '</thead>';
                    html += '<tbody>';
                    $.each(return_obj.return_goods, function(k, v) {
                        html += '<tr>';
                        html += '<td>' + v.goodsName + '</td>';
                        html += '<td class="tac">' + v.spec + '</td>';
                        html += '<td class="tac">' + v.goods_amount + '</td>';
                        html += '<td class="tac">' + v.goods_storePrice + '</td>';
                        html += '<td class="tac">' + v.buyMoney.toFixed(2) + '</td>';
                        html += '</tr>';
                    });
                    html += '</tbody>';
                    html += '</table>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label>配送自购金额：</label>';
                    html += '<label style="font-size: 15px;">'+purchase_price.toFixed(2)+'</label>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label>说明：配送自购金额=退货商品销售价*0.5+退货商品的配件总金额</label>';
                    html += '</div>';




                    E.popup.open({
                        title:  '配送自购详情',
                        content: html,
                        css: 'width: 800px;',
                        btnName:  '确认自购',
                        btnCall: "bill.view.retSave('"+purchase_price+"');"
                    });

                } else {
                    E.alert(o.message);
                }

            },
            retSave: function(purchase_price) {
                E.loadding.open('正在配送自购，请稍候...');
                E.ajax_post({
                    url:  '/invokingAjax-backend/bill/billReturn.ajax?operFlg=103',
                    data: {
                        return_no: bill.return_no,
                        purchase_price:purchase_price
                    },
                    call:  function( o ) {
                        E.loadding.close();
                        if (o.code == 200) {
                            E.alert('自购订单'+bill.return_no+'成功，自购金额'+purchase_price+'元。已计入《配送回款统计报表》《订单支付审核表》中。',2);
                            bill.load();
                            E.popup.close();
                        } else {
                            E.alert(o.message);
                        }
                    }
                });
            },
            //add by allen.qiang 20141110 FUN-BK-0022-配送部自购业务需求 --end

            result: function( o ) {

                if (o.code == 200) {

                    var return_obj = o.data;

                    var html = '<div class="panel panel-default form-horizontal">';
                    html += '<div class="panel-heading">退货单详情</div>';
                    html += '<div class="panel-body">';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">退货单编号</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.return_no + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">订单号</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.bill_code + '</p>';
                    html += '</div>';
                    html += '</div>';

                    //add by 20141028 sunqiang FUN-BK-0012 退货单默认退货金额 start
                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">运费</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.deliver_feePaid + '</p>';
                    html += '</div>';
                    html += '</div>';
                    //add by 20141028 sunqiang FUN-BK-0012 退货单默认退货金额 end
                    if (return_obj.return_reason_2 == null || return_obj.return_reason_2 == 'null') {
                        return_obj.return_reason_2 = '';
                    }

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">退货原因</label>';
                    html += '<div class="col-sm-3">';
                    html += '<p class="form-control-static">' + return_obj.return_reason_1 + '</p>';
                    html += '</div>';
                    html += '<label class="col-sm-1 control-label">内容</label>';
                    html += '<div class="col-sm-4">';
                    html += '<p class="form-control-static">' + return_obj.return_reason_2 + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">问题描述</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.return_memo + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">商品返回方式</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.goods_return_type_name + '</p>';
                    html += '</div>';
                    html += '</div>';

                    if(return_obj.coupon){
                        $.each(return_obj.coupon,function(key,value){
                            if(!E.isEmpty(value.coupon_code)){
                                html += '<div class="form-group">';
                                html += '<label class="col-sm-2 control-label">优惠券</label>';
                                html += '<div class="col-sm-10">';
                                html += '<p class="form-control-static">' + value.coupon_name + '('+ value.coupon_code +')' + '</p>';
                                html += '</div>';
                                html += '</div>';
                            }
                        });
                    }
                    if(return_obj.card){
                        $.each(return_obj.card,function(key,value){
                            if(!E.isEmpty(value.card_no)){
                                html += '<div class="form-group">';
                                html += '<label class="col-sm-2 control-label">现金卡</label>';
                                html += '<div class="col-sm-10">';
                                html += '<p class="form-control-static">' + value.card_name + '('+ value.card_no +')' + '</p>';
                                html += '</div>';
                                html += '</div>';
                            }
                        });
                    }

                    if(return_obj.pay){
                        $.each(return_obj.pay,function(key,value){
                            html += '<div class="form-group">';
                            html += '<label class="col-sm-2 control-label">'+value.payTypeName+'</label>';
                            html += '<div class="col-sm-10">';
                            html += '<p class="form-control-static">' + value.return_pay + '</p>';
                            html += '</div>';
                            html += '</div>';
                        });
                    }

                    if (return_obj.goods_return_type == 2) {
                        var addr = return_obj.pick_province + return_obj.pick_city + return_obj.pick_county + return_obj.pick_address;
                        html += '<div class="form-group">';
                        html += '<label class="col-sm-2 control-label">取货地址</label>';
                        html += '<div class="col-sm-10">';
                        html += '<p class="form-control-static">' + addr + '</p>';
                        html += '</div>';
                        html += '</div>';
                    }

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">联系人姓名</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.custName + '</p>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="form-group">';
                    html += '<label class="col-sm-2 control-label">手机号码</label>';
                    html += '<div class="col-sm-10">';
                    html += '<p class="form-control-static">' + return_obj.mobile + '</p>';
                    html += '</div>';
                    html += '</div>';
                    html += '</div>';
                    html += '</div>';

                    html += '<div class="panel panel-default">';
                    html += '<div class="panel-heading">退货商品</div>';
                    html += '<table class="table">';
                    html += '<thead>';
                    html += '<tr>';
                    html += '<th width="180">商品编号</th>';
                    html += '<th width="*">商品名称</th>';
                    html += '<th width="100">规格</th>';
                    html += '<th width="100">销售价</th>';
                    html += '<th width="100">配件费</th>';
                    html += '<th width="80">退货数量</th>';
                    html += '</tr>';
                    html += '</thead>';
                    html += '<tbody>';
                    $.each(return_obj.return_goods, function(k, v) {
                        html += '<tr>';
                        html += '<td>' + v.goodsID + '</td>';
                        html += '<td>' + v.goodsName + '</td>';
                        html += '<td>' + v.spec + '</td>';
                        //mod by 20141028 sunqiang FUN-BK-0012 退货单默认退货金额 start
                        html += '<td>' + v.goods_purchasePrice + '</td>';
                        html += '<td>' + v.buyMoney.toFixed(2) + '</td>';
                        //mod by 20141028 sunqiang FUN-BK-0012 退货单默认退货金额 end
                        html += '<td class="tac">' + v.goods_amount + '</td>';
                        html += '</tr>';
                    });
                    //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- start
                    html += '</tbody></table></div>';


                    html += '<div class="panel panel-default">';
                    html += '<div class="panel-heading">退货单日志</div>';
                    html += '<table class="table">';
                    html += '<thead>';
                    html += '<tr>';
                    html += '<th width="180">操作时间</th>';
                    html += '<th width="180">操作者</th>';
                    html += '<th width="*">操作内容</th>';
                    html += '<th width="100">状态</th>';
                    html += '</tr>';
                    html += '</thead>';
                    html += '<tbody>';

                    if(return_obj.log != undefined)
                    {

                        $.each(return_obj.log, function(k, v) {
                            html += '<tr>';
                            html += '<td>' + v.createTime + '</td>';
                            html += '<td>' + v.creator + '</td>';
                            html += '<td>' + v.extend_1 + '<br />' + v.extend_2 + '</td>';
                            var status = '';
                            if(v.extend_5==1)
                            {
                                status = '未审核';
                            }
                            else if(v.extend_5==2)
                            {
                                status = '已审核';
                            }
                            else if(v.extend_5==3)
                            {
                                status = '已收货';
                            }
                            else if(v.extend_5==4)
                            {
                                status = '已取消';
                            }
                            else if(v.extend_5==5)
                            {
                                status = '已配送自购';
                            }

                            html += '<td>' + status + '</td>';


                            html += '</tr>';
                        });
                    }
                    //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- end
                    html += '</tbody>';
                    html += '</table>';
                    html += '</div>';

                    if (this.operFlg == 0) {

                        E.popup.open({
                            title: '退货单信息',
                            content: html,
                            css: 'width: 800px;'
                        });

                    } else if(this.operFlg == 3){

                        E.popup.open({
                            title:  '收货确认',
                            content: html,
                            css: 'width: 800px;',
                            btnName:  '确认收货',
                            btnCall: 'bill.receiving.execute();'
                        });

                    }else {

                        E.popup.open({
                            title: this.operFlg == 2 ? '审核退货单' : '取消退货单',
                            content: html,
                            css: 'width: 800px;',
                            btnName: this.operFlg == 2 ? '审核退货单' : '取消退货单',
                            btnCall: this.operFlg == 2 ? 'bill.audit.execute();' : 'bill.cancel.execute();'
                        });

                    }

                } else {
                    E.alert(o.message);
                }

            }

        },

        audit: {

            execute: function() {
                E.loadding.open('正在审核退货单，请稍候...');
                E.ajax_post({
                    url:  '/invokingAjax-backend/bill/billReturn.ajax?operFlg=100',
                    data: {
                        return_no: bill.return_no
                    },
                    call: 'bill.audit.result'
                });
            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {
                    E.alert('审核成功', 2);
                    bill.load();
                    E.popup.close();
                } else {
                    E.alert(o.message);
                }

            }

        },

        cancel: {

            execute: function() {
                E.loadding.open('正在取消退货单，请稍候...');
                E.ajax_post({
                    url:  '/invokingAjax-backend/bill/billReturn.ajax?operFlg=101',
                    data: {
                        return_no: bill.return_no
                    },
                    call: 'bill.cancel.result'
                });
            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {
                    E.alert('取消成功', 2);
                    bill.load();
                    E.popup.close();
                } else {
                    E.alert(o.message);
                }

            }

        },

        receiving: {

            execute: function() {
                E.loadding.open('正在保存，请稍候...');
                E.ajax_post({
                    url:  '/invokingAjax-backend/bill/billReturn.ajax?operFlg=102',
                    data: {
                        return_no: bill.return_no
                    },
                    call: 'bill.receiving.result'
                });
            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {
                    E.alert('收货成功', 2);
                    bill.load();
                    E.popup.close();
                } else {
                    E.alert(o.message);
                }

            }

        },
        //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- start
        QC:{

            return_no:'',
            addQC: function( return_no ) {
                bill.QC.return_no = return_no;
                var html = '<div  class="form-horizontal">';

                html += ' <div class="form-group">';
                html += ' <label class="col-sm-3 control-label"> 退货单编号：</label>';
                html += ' <div class="col-sm-9">';
                html += ' <label class="control-label">' + return_no +'</label>';
                html += ' </div>';
                html += ' </div>';

                html += ' <div class="form-group"> ';
                html += ' <label class="col-sm-3 control-label"> 责任部门：</label>';
                html += ' <div class="col-sm-9">';
                html += ' <select class="form-control input-sm w300" id="qcviews_dept" >';
                <!--{foreach from=$qcviews_items item=op}-->
                html += '<option value="<!--{$op.item_name}-->"><!--{$op.item_name}--></option>';
                <!--{/foreach}-->
                html += ' </select>';
                html += ' </div>';
                html += ' </div>';

                html += ' <div class="form-group">';
                html += ' <label class="col-sm-3 control-label"> 品控意见：</label>';
                html += ' <div class="col-sm-9">';
                html += ' <textarea  class="form-control w300" id="qcviews_remark" maxlength="60" name="qcviews_remark"></textarea>';
                html += ' </div>';
                html += ' </div>';

                html += '</div>';

                E.popup.open({
                    title: '新增品控意见',
                    content: html,
                    css: 'width: 500px;',
                    btnName:  '确定',
                    btnCall: 'bill.QC.execute(1);'
                });
            },
            updateQC: function ( return_no ) {
                bill.QC.return_no = return_no;

                E.ajax_post({
                    url: '/invokingAjax-backend/bill/billReturn.ajax?operFlg=10',
                    data: {
                        return_no: bill.QC.return_no
                    },
                    call: function( result ){
                        var html = '<div  class="form-horizontal">';

                        html += ' <div class="form-group">';
                        html += ' <label class="col-sm-3 control-label"> 退货单编号：</label>';
                        html += ' <div class="col-sm-9">';
                        html += ' <label class="control-label">' + return_no +'</label>';
                        html += ' </div>';
                        html += ' </div>';

                        html += ' <div class="form-group"> ';
                        html += ' <label class="col-sm-3 control-label"> 责任部门：</label>';
                        html += ' <div class="col-sm-9">';
                        html += ' <select class="form-control input-sm w300" id="qcviews_dept" >';
                        <!--{foreach from=$qcviews_items item=op}-->
                            if( result.data.qcviews_dept == "<!--{$op.item_name}-->" )
                            {
                                html += '<option value="<!--{$op.item_name}-->" selected="selected"><!--{$op.item_name}--></option>';
                            }
                            else
                            {
                                html += '<option value="<!--{$op.item_name}-->"><!--{$op.item_name}--></option>';
                            }
                        <!--{/foreach}-->
                        html += ' </select>';
                        html += ' </div>';
                        html += ' </div>';
                        html += ' <div class="form-group">';
                        html += ' <label class="col-sm-3 control-label"> 品控意见：</label>';
                        html += ' <div class="col-sm-9">';
                        html += ' <textarea  class="form-control w300" id="qcviews_remark" maxlength="60" name="qcviews_remark">'+result.data.qcviews_remark+'</textarea>';
                        html += ' </div>';
                        html += ' </div>';

                        html += '</div>';




                        E.popup.open({
                            title: '修改品控意见',
                            content: html,
                            css: 'width: 500px;',
                            btnName:  '确定',
                            btnCall: 'bill.QC.execute(2);'
                        });

                    }
                });







            },
            execute: function (type)
            {
                var dept = $("#qcviews_dept").val();
                var remark = $("#qcviews_remark").val();
                var url = '/invokingAjax-backend/bill/billReturn.ajax?operFlg=8';
                if(type==1)
                {
                    url = '/invokingAjax-backend/bill/billReturn.ajax?operFlg=8';
                }
                else
                {
                    url = '/invokingAjax-backend/bill/billReturn.ajax?operFlg=9';
                }

                E.loadding.open('正在保存，请稍候...');
                E.ajax_post({
                    url: url,
                    data: {
                        return_no: bill.QC.return_no,
                        dept:dept,
                        remark:remark
                    },
                    call: 'bill.QC.result'
                });
            },
            result:function ( o )
            {
                E.loadding.close();
                if (o.code == 200) {
                    E.alert(o.message, 2);
                    bill.load();
                    E.popup.close();
                } else {
                    E.alert(o.message);
                }
            }

        }
        //add by sun.qiang  2015-03-25 MK-FUN-BK-004 新增品控意见 --- end

    };

    $('#startDate').datepicker();
    $('#endDate').datepicker();
    $('#auditStartDate').datepicker();
    $('#auditEndDate').datepicker();
    //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--start
    $('#sendDate').datepicker();
    //add by allen.qiang 20141023 退货单增加“配送日期”作为查询条件--end

    <!--{if isset($kf_return_no)}-->
    bill.view.open(<!--{$kf_return_no}-->, 0);
    <!--{/if}-->

</script>
<script type="text/javascript" src="/framework/ebsig/js/item.js"></script>
<script type="text/javascript">
    get_second_item(14);
</script>

</body>
</html>